package SwingComponents;

import Connection.IPServer;
import Controllers.Application;
import java.awt.Color;
import java.awt.Dimension;
import java.io.File;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.net.URL;

public class CongratulationsPanel extends TransparentPanel {

    public CongratulationsPanel(Application application) {
        try {
            IPServer iPServer = new IPServer(application);
            this.setBackground(Color.BLACK);
            this.setVisible(true);
            this.setSize(new Dimension(501, 701));
            this.setMaximumSize(new Dimension(501, 701));
            this.setMinimumSize(new Dimension(501, 701));
            this.setPreferredSize(new Dimension(501, 701));
            this.setBackgroundImage(createImage(new URL(iPServer.getAdress() + "/Images/congratulations.png")));
        } catch (Exception e) {
            try {
                File file = new File("C:/CongratulationsPanel_CongratulationsPanel.txt");
                file.createNewFile();
                FileOutputStream fileOutputStream = new FileOutputStream(file);
                ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
                objectOutputStream.writeObject(e.getMessage());
                objectOutputStream.flush();
                objectOutputStream.close();
            } catch (Exception ex) {
            }
        }
    }
}
